package org.dwell.vertx3.demos.core;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;

/**
 * Created by JianGuo on 2016/1/14.
 */
public class VerticleDemo {
    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        MyVerticle myVerticle = new MyVerticle();
        vertx.deployVerticle(myVerticle);
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static class MyVerticle extends AbstractVerticle {
        //called when verticle is deployed
        @Override
        public void start() throws Exception {
            System.out.println("MyVerticle Verticle started!");
            vertx.deployVerticle("org.dwell.vertx3.demos.core.AsynchronousVerticle", res -> {
                if(res.succeeded()) {
                    System.out.println("Asynchronous Deploy Succeed ! ");
                }
            });
        }

        //called when verticle is undeployed
        @Override
        public void stop() throws Exception {
            System.out.println("MyVerticle Verticle has been stoped!");
        }
    }
}
